/*     */ package com.zimbra.qa.unittest.prov.ldap;
/*     */ 
/*     */ import com.zimbra.cs.account.AccountServiceException;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import com.zimbra.cs.account.Zimlet;
/*     */ import com.zimbra.qa.unittest.prov.Names;
/*     */ import com.zimbra.soap.admin.type.CacheEntryType;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.junit.Assert;
/*     */ import org.junit.BeforeClass;
/*     */ import org.junit.Test;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class TestLdapProvZimlet
/*     */   extends LdapTest
/*     */ {
/*     */   private static LdapProvTestUtil provUtil;
/*     */   private static Provisioning prov;
/*     */   
/*     */   @BeforeClass
/*     */   public static void init()
/*     */     throws Exception
/*     */   {
/*  38 */     provUtil = new LdapProvTestUtil();
/*  39 */     prov = provUtil.getProv();
/*     */   }
/*     */   
/*     */   private Zimlet createZimlet(String zimletName) throws Exception {
/*  43 */     Zimlet zimlet = prov.getZimlet(zimletName);
/*  44 */     Assert.assertNull(zimlet);
/*     */     
/*  46 */     Map<String, Object> attrs = new HashMap();
/*  47 */     attrs.put("zimbraZimletVersion", "1.0");
/*  48 */     zimlet = prov.createZimlet(zimletName, attrs);
/*  49 */     Assert.assertNotNull(zimlet);
/*     */     
/*  51 */     prov.flushCache(CacheEntryType.zimlet, null);
/*  52 */     zimlet = prov.getZimlet(zimletName);
/*  53 */     Assert.assertNotNull(zimlet);
/*  54 */     Assert.assertEquals(zimletName.toLowerCase(), zimlet.getName().toLowerCase());
/*     */     
/*  56 */     return zimlet;
/*     */   }
/*     */   
/*     */   private void deleteZimlet(Zimlet zimlet) throws Exception {
/*  60 */     String zimletName = zimlet.getName();
/*  61 */     prov.deleteZimlet(zimletName);
/*  62 */     zimlet = prov.getZimlet(zimletName);
/*  63 */     Assert.assertNull(zimlet);
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void createZimlet() throws Exception {
/*  68 */     String ZIMLET_NAME = Names.makeZimletName(genZimletName());
/*  69 */     Zimlet zimlet = createZimlet(ZIMLET_NAME);
/*     */     
/*  71 */     deleteZimlet(zimlet);
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void createZimletAlreadyExists() throws Exception {
/*  76 */     String ZIMLET_NAME = Names.makeZimletName(genZimletName());
/*  77 */     Zimlet zimlet = createZimlet(ZIMLET_NAME);
/*     */     
/*  79 */     boolean caughtException = false;
/*     */     try {
/*  81 */       Map<String, Object> attrs = new HashMap();
/*  82 */       attrs.put("zimbraZimletVersion", "1.0");
/*  83 */       zimlet = prov.createZimlet(ZIMLET_NAME, attrs);
/*     */     } catch (AccountServiceException e) {
/*  85 */       if ("account.ZIMLET_EXISTS".equals(e.getCode())) {
/*  86 */         caughtException = true;
/*     */       }
/*     */     }
/*  89 */     Assert.assertTrue(caughtException);
/*     */     
/*  91 */     deleteZimlet(zimlet);
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void listAllZimlets() throws Exception {
/*  96 */     List<Zimlet> allZimlets = prov.listAllZimlets();
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void getZimlet() throws Exception
/*     */   {
/* 102 */     String ZIMLET_NAME = Names.makeZimletName(genZimletName());
/* 103 */     Zimlet zimlet = createZimlet(ZIMLET_NAME);
/*     */     
/* 105 */     prov.flushCache(CacheEntryType.zimlet, null);
/* 106 */     zimlet = prov.getZimlet(ZIMLET_NAME);
/* 107 */     Assert.assertEquals(ZIMLET_NAME.toLowerCase(), zimlet.getName().toLowerCase());
/*     */     
/* 109 */     deleteZimlet(zimlet);
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void getZimletNotExist() throws Exception {
/* 114 */     String ZIMLET_NAME = Names.makeZimletName(genZimletName());
/* 115 */     Zimlet zimlet = prov.getZimlet(ZIMLET_NAME);
/* 116 */     Assert.assertNull(zimlet);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/prov/ldap/TestLdapProvZimlet.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */